<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>碳达人</title>
    <link rel="stylesheet" th:href="@{/libs/bootstrapvalidator/css/bootstrapValidator.min.css}"/>
    <link rel="stylesheet" th:href="@{/libs/fireui/accordion.css}"/>
    <link rel="stylesheet" th:href="@{/libs/fireui/table.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/calculator.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/customer-20211209.css}"/>
</head>
<body>
<header id="header">
    <div th:replace="home/cfragments/navbar :: cnavbar"></div>
</header>
<span th:if="${CURRENT_CUSTOMER == null}">
    <span id="no_login"></span>
</span>


<div class="main-container">
    <div class="content">
        <!--算法二-->
        <form class="form-horizontal" id="eghgTwoForm">
            <div class="calc_two_main">
                <div class="calc_two_content calc_two_main_left">
                    <div id="accordion" role="tablist" class="fire_accordion_common fire_accordion1">
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOne" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>E<sub>CO<sub>2</sub>_燃烧</sub>：化石燃料燃烧产生的CO<sub>2</sub>排放，单位为t
                            </a>
                            <div id="collapseOne" class="collapse in">
                                <div class="card-body">
                                    </br>AD<sub>i</sub>:化石燃料i用作燃料燃烧的消费量，对固体和液体燃料以t为单位，对气体燃料以10<sup>4</sup>Nm<sup>3</sup>为单位
                                    </br>CC<sub>i</sub>:化石燃料i的含碳量，对固体和液体燃料以t为单位，对气体燃料以t /10<sup>4</sup>Nm<sup>3</sup>为单位
                                    </br>OF<sub>i</sub>:化石燃料的碳氧化率，单位为%
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneyl" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>E<sub>CO<sub>2</sub>_原料</sub>：化石燃料和其他碳氢化合物用作原材料生产的CO<sub>2</sub>排放，单位为t
                            </a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOnetsy" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>E<sub>CO<sub>2</sub>_碳酸盐</sub>：碳酸盐使用过程产生的CO<sub>2</sub>排放，单位为t</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOnexs" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>E<sub>CO<sub>2</sub>_硝酸</sub>：硝酸生成过程的N<sub>2</sub>O排放，单位为t</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneyes" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>E<sub>CO<sub>2</sub>_己二酸</sub>：己二酸生成过程的N<sub>2</sub>O排放，单位为t</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneq" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i> Q：企业边界回收且外供的CO<sub>2</sub>气体体积，单位为10<sup>4</sup>Nm<sup>3</sup></a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOnepupco2" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>PURCO<sub>2</sub>：CO<sub>2</sub>外供气体的纯度，单位为%</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneaddl" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>AD<sub>电力</sub>：企业净购入的电力消费，单位为MWh</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneefld" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>EF<sub>电力</sub>：企业净购入的热力消费，单位为GJ</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneadrl" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>AD<sub>热力</sub>：电力供应的CO<sub>2</sub>排放因子，单位为t/MWh</a>
                        </div>
                        <div class="card">
                            <a data-toggle="collapse" class="title" href="#collapseOneefrl" role="button"
                               aria-expanded="true">
                                <i class="fa fa-angle-down"></i>EF<sub>热力</sub>：热力供应的CO<sub>2</sub>排放因子，单位为t/GJ</a>
                        </div>
                    </div>
                </div>
                <div class="calc_two_content calc_two_main_right">
                    <div class="calc_top calc_two_main_right_content">
                        <div class="form-group">
                            <label for="eco2BurnTwo"
                                   class="col-sm-4 control-label">E<sub>CO<sub>2</sub>_燃烧</sub></label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" name="eco2Burn" readonly id="eco2BurnTwo"
                                       placeholder="请输入企业净购入的热力消费引起的CO2排放">
                            </div>
                        </div>
                    </div>
                    <div class="calc_table calc_two_main_right_content">
                        <div class="table_style1 table_style2 table-responsive">
                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th style="width: 25%;">
                                        <button type="button" class="btn btn-primary"
                                                onclick="addEco2Burn()">添加
                                        </button>
                                    </th>
                                    <th style="width: 25%">AD<sub>i</sub></th>
                                    <th style="width: 25%">CC<sub>i</sub></th>
                                    <th style="width: 25%">OF<sub>i</sub></th>
                                </tr>
                                </thead>
                                <tbody id="eco2BurnTbody">

                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="calc_center calc_two_main_right_content">
                        <div class="form-group">
                            <label for="eco2RawMaterial"
                                   class="col-sm-3 control-label">E<sub>CO<sub>2</sub>_原料</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="eco2RawMaterial"
                                       id="eco2RawMaterial">
                            </div>
                            <label for="eco2Nitrate"
                                   class="col-sm-3 control-label">E<sub>CO<sub>2</sub>_碳酸盐</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="eco2Nitrate" id="eco2Nitrate">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="en2oNitricAcid"
                                   class="col-sm-3 control-label">E<sub>N<sub>2</sub>O_硝酸</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="en2oNitricAcid"
                                       id="en2oNitricAcid">
                            </div>
                            <label for="en2oAdipicAcid"
                                   class="col-sm-3 control-label">E<sub>N<sub>2</sub>O_己二酸</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="en2oAdipicAcid"
                                       id="en2oAdipicAcid">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="q" class="col-sm-3 control-label">Q</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="q" id="q">
                            </div>
                            <label for="purCo2" class="col-sm-3 control-label">PURCO<sub>2</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="purCo2" id="purCo2">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="adPower" class="col-sm-3 control-label">AD<sub>电力</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="adPower" id="adPower">
                            </div>
                            <label for="efPower" class="col-sm-3 control-label">EF<sub>电力</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="efPower" id="efPower">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="adHeat" class="col-sm-3 control-label">AD<sub>热力</sub></label>
                            <div class="col-sm-3">
                                <select class="form-control" name="adHeat" id="adHeat">
                                    <option value="0">请选择</option>
                                    <option value="0.9419">0.9419(华北电网)</option>
                                    <option value="1.0826">1.0826(东北电网)</option>
                                    <option value="0.7921">0.7921(华东电网)</option>
                                    <option value="0.8587">0.8587(华中电网)</option>
                                    <option value="0.8922">0.8922(西北电网)</option>
                                    <option value="0.8042">0.8042(南方电网)</option>
                                </select>
                            </div>
                            <label for="efHeat" class="col-sm-3 control-label">EF<sub>热力</sub></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="efHeat" id="efHeat" value="0.11"
                                       readonly>
                            </div>
                        </div>
                    </div>
                    <div style="width: 100%; float: left">
                        <div class="calc_line"></div>
                    </div>
                    <div class="calc_bottom calc_two_main_right_content">
                        <button class="btn btn-info waves-effect waves-light btn-sm" style="float: left"
                                onclick="getEco2BurnTwo()"
                                type="button">计算&nbsp;&nbsp;&nbsp;&nbsp;E<sub>GHG</sub>
                        </button>
                        <div id="eghgTwoResult"></div>
                    </div>
                </div>
            </div>
            <div class="calc_one_other">
                <div class="calc_one_other_left calc_one_other_main" id="calculator_one">
                    <div class="title">个人用户使用</div>
                    <div class="content">简易版</div>
                </div>
                <div class="calc_one_other_right calc_one_other_main" id="calculator_three">
                    <div class="title">企业用户专享</div>
                    <div class="content">专业版</div>
                </div>
            </div>
        </form>
    </div>
</div>
<div>
    <div th:replace="home/cfragments/float_right :: cfloatright"></div>
</div>
<div class="footer">
    <div th:replace="home/cfragments/footer :: cfooter"></div>
</div>
<script th:src="@{/libs/bootstrap/bootstrap.min.js}"></script>
<script th:src="@{/libs/bootstrapvalidator/js/bootstrapValidator.js}"></script>
<script>

    $(function () {
        $('#tdr').addClass('th-bg');
        if ($('#no_login').length == 1) {
            userLogin();
        }

        $('#calculator_one').click(function () {
            window.location.href = '/blog/calculator/one';
        });

        $('#calculator_three').click(function () {
            window.location.href = '/blog/calculator/three';
        });


        $('#eghgTwoForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                eco2RawMaterial: {
                    message: '化石燃料和其它碳氢化合物用作原材料产生的CO2排放验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入化石燃料和其它碳氢化合物用作原材料产生的CO2排放'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{4}$/,
                            message: '只能输入保留四位小数的数字'
                        }
                    }
                },
                eco2Nitrate: {
                    message: '碳酸盐使用过程产生的CO2排验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入碳酸盐使用过程产生的CO2排放'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{4}$/,
                            message: '只能输入保留四位小数的数字'
                        }
                    }
                },
                en2oNitricAcid: {
                    message: '硝酸生产过程的N2O排放验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入硝酸生产过程的N2O排放'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                },
                en2oAdipicAcid: {
                    message: '己二酸生产过程的N2O排放验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入己二酸生产过程的N2O排放'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                },
                q: {
                    message: '企业边界回收且外供的CO2气体体积验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入该企业边界回收且外供的CO2气体体积，单位为万Nm3'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                },
                purCo2: {
                    message: 'CO2外供气体的纯度验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入CO2外供气体的纯度，单位为%'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                },
                adPower: {
                    message: '企业净购入的电力消费验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入企业净购入的电力消费，单位为MWh'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                },
                efPower: {
                    message: '企业净购入的热力消费验证失败',
                    validators: {
                        notEmpty: {
                            message: '请输入企业净购入的热力消费，单位为 GJ（百万千焦）'
                        },
                        regexp: {
                            regexp: /^[0-9]+\.[0-9]{2}$/,
                            message: '只能输入保留两位小数的数字'
                        }
                    }
                }
            }
        });

        $('.one').mouseover(function () {
            enterCard($(this));
        });

        $('.one').mouseout(function () {
            outCard($(this));
        });

        $('.two').mouseover(function () {
            enterCard($(this));
        });

        $('.two').mouseout(function () {
            outCard($(this));
        });

        $('.three').mouseover(function () {
            enterCard($(this));
        });

        $('.three').mouseout(function () {
            outCard($(this));
        });
    });

    function enterCard(obj) {
        //边框变蓝色
        obj.find('div').addClass('card-main-mouseenter');
        obj.find('button').addClass('card-button-mouseenter')
    }

    function outCard(obj) {
        obj.find('div').removeClass('card-main-mouseenter')
        obj.find('button').removeClass('card-button-mouseenter')
    }

    function addEco2Burn() {
        var delTd = '<td></td>';
        var adiTd = '<td><input type="text" class="form-control" name="adi" onkeyup="this.value=this.value.replace(/^(\\-)*(\\d+)\\.(\\d\\d).*$/,\'$1$2.$3\')"></td>';
        var cciTd = '<td><input type="text" class="form-control" name="cci" onkeyup="this.value=this.value.replace(/^(\\-)*(\\d+)\\.(\\d\\d).*$/,\'$1$2.$3\')"></td>';
        var ofiTd = '<td colspan="1">' +
            '<select class="form-control" name="ofi">' +
            '<option value="0">请选择</option>' +
            '<option value="0.98">0.98(液体)</option>' +
            '<option value="0.99">0.99(气体)</option>' +
            '<option value="0.94">0.94(无烟煤)</option>' +
            '<option value="0.93">0.93(烟煤)</option>' +
            '<option value="0.96">0.96(褐煤)</option>' +
            '<option value="0.93">0.93(焦炭)</option>' +
            '<option value="0.90">0.90(其他)</option>' +
            '</select></td>';
        $('#eco2BurnTbody').append('<tr>' + delTd + '' + adiTd + '' + cciTd + '' + ofiTd + '</tr>');
    }

    function getEco2BurnTwo() {
        var adi = $('input[name="adi"]');
        var cci = $('input[name="cci"]');
        var ofi = $('select[name="ofi"]');
        if (adi.length == cci.length && adi.length == ofi.length) {
            var flag = $('#eghgTwoForm').data('bootstrapValidator').isValid();
            if (flag) {
                Core.postAjax("/blog/eghg/api/eghgtwo", $('#eghgTwoForm').serialize(), function (data) {
                    $('#eghgTwoResult').html(data.data.result)
                    $('#eco2BurnTwo').val(data.data.eco2Burn);
                });
            }
        }

    }
</script>
</body>
</html>